package rpc.client;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.net.InetSocketAddress;
import java.util.Map;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

@Configuration
public class ConnectPool {

    @Bean
    public Map<InetSocketAddress, RpcClientHandler> connectedServerNodes(){
        return new ConcurrentHashMap<>();
    }

    @Bean
    public ThreadPoolExecutor threadPoolExecutor(){
        return new ThreadPoolExecutor(16, 16,
                600L, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(65536));
    }
}
